/*Author:no-bald-chen
 * Time:2021/8/26
 * */
package Algorithm.sort;

public class Bubble_sort {
    public void sort(int[] nums){
        if (nums.length==0){
            return;
        }
        for (int i = nums.length-1; i >=0; i--) {
            for (int j = 0; j < i; j++) {
                if (nums[j]>nums[j+1]){
                    swap(j,j+1,nums);
                }
            }
        }
    }

    public void swap(int i ,int j,int[] nums){
        int temp =nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }
}
